﻿using System;
using GameCore.Mapping.Format;
using Microsoft.Xna.Framework.Content;
using GameCore.Mapping;
using System.IO;

namespace GameCore.Readers
{
    class MapReader : ContentTypeReader<Map>
    {
        protected override Map Read(ContentReader input, Map existingInstance)
        {
            int dataLength = input.ReadInt32();
            byte[] data = input.ReadBytes(dataLength);

            using (MemoryStream memoryStream = new MemoryStream(data))
            {
                Map map = FormatManager.Instance.BinaryFormat.Load(memoryStream);
                return map;
            }
        }
    }
}
